import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import base from '@src/store/base'
import router from '@src/router'
import { getAccountRule } from '@src/api/member'
Component({
  /**
   * 组件的属性列表
   */
  behaviors: [storeBindingsBehavior],
  storeBindings: [
    {
      store: base,
      fields: ['themeColor', 'themeTitleColor']
    }
  ],
  properties: {
    modules: {
      type: Array,
      value: "",
    },
    login: {
      type: Boolean
    }
  },
  options: {
    multipleSlots: true,
    addGlobalClass: true
  },
  /**
   * 组件的初始数据
   */
  data: {
    defaultAmountArray: [],
    pic: ""
  },
  lifetimes: {
    attached: function () {
      let modulesData = this.data.modules[0];
      let pic = modulesData.pic;
      this.setData({ pic })
      this.initData()
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    rechargeTap() {
      if (!this.data.login) { this.triggerEvent('login'); return; }
      router.push({ name: 'member/balanceRecharge' })
    },
    initData() {
      getAccountRule().then(res => {
        if (res.code == 0) {
          let defaultAmountArray = res.data.defaultAmount.split(",");
          this.setData({ defaultAmountArray })
        }
      })
    }
  }
})
